package Locomotive;

import java.awt.Color;
import java.awt.geom.Point2D;

/**
 *
 * @author Mikael Köhlmyr | mikael@kohlmyr.com | http://www.kmyr.net
 */
public class Util {
    public static final Color[] COLORS = {Color.GREEN, Color.BLUE, Color.RED, Color.YELLOW, Color.PINK, Color.CYAN, Color.MAGENTA};

    public static void print_exception(Exception ex){
        System.out.println("Exception > " + ex.getMessage());
    }

    public static Color get_random_color(){
        return COLORS[(int)(Math.random() * (COLORS.length-1))];
    }

    public static int get_random_buffered_integer(int max, int buffer){
        return (int)((Math.random()*(max-buffer))+buffer);
    }

    public static double get_random_pivoted_double(int max){
        return ((Math.random() * max) + ((-1) * (max/2)));
    }
    
    public static Point2D.Double get_random_pivoted_point(int max){
        return new Point2D.Double(Util.get_random_pivoted_double(max), Util.get_random_pivoted_double(max));
    }

    public static Point2D.Double get_random_buffered_point_in_bounds(int width, int height, int buffer){
        return new Point2D.Double((Math.random() * (width-buffer) + (buffer/2)), (Math.random() * (height-buffer) + (buffer/2)));
    }
}
